<script lang="ts" setup>
import * as echarts from 'echarts';
import { onMounted } from 'vue';


onMounted(() => {
    var ROOT_PATH = 'https://echarts.apache.org/examples';

    var chartDom = document.getElementById('water');
    var myChart = echarts.init(chartDom);
    var option;

    const weatherIcons = {
        Sunny: ROOT_PATH + '/data/asset/img/weather/sunny_128.png',
        Cloudy: ROOT_PATH + '/data/asset/img/weather/cloudy_128.png',
        Showers: ROOT_PATH + '/data/asset/img/weather/showers_128.png'
    };
    option = {
        title: {
            left: 'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
            bottom: 10,
            left: 'center',
            data: ['CityA', 'CityB', 'CityD', 'CityC', 'CityE']
        },
        series: [
            {
                type: 'pie',
                radius: '65%',
                center: ['50%', '50%'],
                selectedMode: 'single',
                data: [
                    {
                        value: 1548,
                        name: 'I类水质 5个  38%',
                    },
                    { value: 735, name: 'II类水质 3个  23%' },
                    { value: 510, name: 'III类水质 2个 15%' },
                    { value: 434, name: 'IV类水质 2个 15%' },
                    { value: 335, name: 'V类水质 1个   7%' }
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };

    option && myChart.setOption(option);
})
</script>

<template>
    <div id="water"></div>
</template>



<style scoped lang="scss">
#water {
    width: 400px;
    height: 280px;
    margin-top: 30px;
}
</style>
